/*
Copyright (c) 2006 - 2008  Universitaet Osnabrueck, virtUOS
Authors: Markus Ketterl, Johannes Emden, Nils Schuhmacher, Andreas Rickling

This file is part of virtPresenter.

virtPresenter is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

virtPresenter is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with virtPresenter.  If not, see <http://www.gnu.org/licenses/>.
*/

package virtPresenter.model
{
		import com.adobe.cairngorm.control.*;
		
		import flash.media.Video;
		import flash.net.NetStream;
		import flash.text.TextField;
		
		import mx.collections.ArrayCollection;
		import mx.containers.ViewStack;
		import mx.controls.ComboBox;
		
		import virtPresenter.event.*;
		import virtPresenter.view.Default;
		import virtPresenter.view.Search;
		import virtPresenter.view.SlideBrowser;	
       	
	[Bindable]
	/**
	 * Model locator of the application due to the MVC paradigm. 
	 */
	public class virtPresenterLocator
	{
		private static var instance:virtPresenterLocator;  		
   		
   		// RED 5
   		/**
      	 *  URI for the RED5 Server 
      	 * */
        public var uri:String =""; 
        
   		/**
   		 * Name of the FLV Video.
   		 * */
      	public var flv:String ="";       
      	
      	
      	// RED5 Player
      	/**
      	 * Netstream where the video comes from.
      	 */
      	public var netStream:NetStream; 
      	/**
      	 * Defines where the video is displayed.
      	 * */
      	public var videoPlayer:Video;             	
      	
      	
      	// COMPONENTS      	
      	/**
      	 * AdvancedScrubber of the application.
      	 * */
      	public var scrubber:AdvancedScrubber;
      	
      	/**
      	 * ViewStack of the application.
      	 * */
      	public var views:ViewStack;        	
      	
      	/**
      	 * Default view component.
      	 * */
        public var defaultView:Default;
        
        /**
        * SlideBrowser view.
        * */
        public var slideBrowserView:SlideBrowser;
        
        /**
        * ComboBox in the Application to select a view
        * */
        public var viewComboBox:ComboBox;
        
            	       
        // COLLECTIONS (containing the XML files content)
        
        public var products:ArrayCollection = new ArrayCollection();
      	
      	/**
      	 * Contains content of lecturerecordings.xml.
      	 * */
      	public var lectures:ArrayCollection = new ArrayCollection();
      	
      	/**
      	 * Contains content of search.xml of current lecture.
      	 * */
      	public var searchCollection:ArrayCollection = new ArrayCollection();
      	
      	/**
      	 * Contains content of logXML.xml of current lecture.
      	 * */
      	public var logCollection:ArrayCollection=new ArrayCollection();
      	
      	/**
      	 * Contains content of mouse.xml of current lecture.
      	 * */
      	public var mouseCollection:ArrayCollection=new ArrayCollection();
        
        
        // XML Objects (containing the XML files content)
        /**
        * XML Object of search.xml
        * */
        public var searchXML:XML;
        
        /**
        * XML Object of logXML.xml
        * */
        public var logXML:XML;
        
        
        // SEARCH
        /**
        * SearchView as a component.
        * */
        public var searchView:Search;
        
        /**
        * SearchProvider that makes the actual search.
        * */
        public var searchProvider:SearchProvider;
        
        /**
        * Initial timepoint for a search result.
        */    
        public var initPoint:int=0;
        
        
        // NAVIGATION and PRESENTATION
        /**
        * Gives the current videotime
        * */
        public var currentvideotime:Number;        
         
        /**
        * Id of the currently shown slide.
        * */
        public var currentSlideID:int;
        public var prevSID:int;
        public var nextSID:int;
        
        /**
        * Step of the current animation.
        * */
        public var currentAnimStep:int;
        public var prevAS:int;
        public var nextAS:int;
        
        public var isLast:Boolean;
        public var isFirst:Boolean;
        
        /**
        * Total number of slides of the current lecture.
        * */
        public var totalNumberOfSlides:int;
        
        
        // LECTURE information
        /**
        * Contributors name of the current lecture.
        * */
        public var dozent:String;
        
        /**
        * Folder of the current lecture. 
        */
        public var lectureFolder:String;
        
        /**
        * Name (title/topic) of the current lecture.
        * */
        public var LectureName:String;     
        
        /**
        * Index of the current lecture in the lecture list.
        * */
        public var currentLectureIndex:int;   
        
        
        // REST        
        /**
         * XMLParser for the current lecture.
         * */
        public var xmlParser:XMLParser;    
  
		/**
		 * The instance for the slideWrapperProxy
		 */
		public var mainWindowProxy:ISlideWrapperProxy;
		public var previewLeftProxy:ISlideWrapperProxy;
		public var previewMiddleProxy:ISlideWrapperProxy;
		public var previewRightProxy:ISlideWrapperProxy;
        
        /**
      	 *  Metadata Object. Contains width, height and duration of the video 
      	 * (metaData.width metaData.height metaData.duration).
      	 */
      	public var metaData:Object;  
      	
        /**
      	 * Index of the selected thumbnail in SlideBrowser 
      	 */
        public var selectedThumbnailIndex : int;
        
        /**
         * Checks wheter all needed xmlFiles are loaded or not.
         */    
        public var xmlReceived:Boolean=false;       
          	
        /**
        * Width of the presentation.
        * */
        public var presentationContentWidth:Number = 0;
        
        /**
        * Heigth of the presentation.
        * */
      	public var presentationContentHeight:Number = 0;
      	
      	/**
      	 * Tooltip for scrubber.
      	 * */      	
      	public var toolTip:TextField;                  
        
        /**
        * Indicates which view the user had selected previously.
        * */
        public var formerView:String;
        
        // Should be removed later.
        /**
        * Selected Color for the application.
        * */
        public var selectedColor:uint;       
        
        //Still used?        
        //public var slidetimefromxml : int;        
       	
        
        //Constructor should be private but current AS3.0 does not allow it yet (?)...
      	/**
      	 * Contructor for VirtPresenterLocator. Is Singleton.
      	 * */
      	public function virtPresenterLocator() 
      	{	
      		trace("virtPresenterLocator. VirtPresenterLocator instance created!");
         	if ( instance != null )
        	{
         		throw new Error( "virtPresenterLocator. Only one virtPresenterLocator instance should be instantiated");         		
         	}  				
      	}	
      	
      	/**
      	 * Delivers the instance of the virtPresenterLocator.
      	 * */
      	public static function getInstance():virtPresenterLocator 
        {
           if (instance == null)
               instance = new virtPresenterLocator();
           return instance;
        }	
			   
	}
}